<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>首页</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="../../layui/css/layui.css"
	media="all">
<link rel="stylesheet" href="../../res/js/tl/admin.css"
	media="all">
<style type="text/css">
	/*滚动条样式*/
    .innerbox::-webkit-scrollbar {/*滚动条整体样式*/
        width: 6px;     /*高宽分别对应横竖滚动条的尺寸*/
        height: 6px;
    }
    .innerbox::-webkit-scrollbar-thumb {/*滚动条里面小方块*/
        border-radius: 10px;
        -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
        background: rgba(0,0,0,0.2);
    }
    .innerbox::-webkit-scrollbar-track {/*滚动条里面轨道*/
        -webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
        border-radius: 0;
        background: rgba(0,0,0,0.1);
    }
    .layui-input{
    	border:none;
    }
    .layui-col-md3{
    	width:20%;
    }
</style>
</head>
<body class="innerbox">
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">

			<div class="layui-col-sm6 layui-col-md3">
				<div class="layui-card">
					<div class="layui-card-header">
						库存预警<span class="layui-badge layui-bg-blue layuiadmin-badge">条</span>
					</div>
					<div class="layui-card-body layuiadmin-card-list">
						<p class="layuiadmin-big-font">9,999,666</p>
						<p>
							<a href="#inventoryRecord" class="layui-btn layui-btn-xs">查看详情</a><span class="layuiadmin-span-color"> <i
								class="layui-inline layui-icon layui-icon-flag"></i></span>
						</p>
					</div>
				</div>
			</div>
			<div class="layui-col-sm6 layui-col-md3">
				<div class="layui-card">
					<div class="layui-card-header">
						今日销量<span class="layui-badge layui-bg-cyan layuiadmin-badge">日</span>
					</div>
					<div class="layui-card-body layuiadmin-card-list">
						<p class="layuiadmin-big-font" id="todaysSales"></p>
						<p>
							本月销量 <span class="layuiadmin-span-color" id="monthSales"><i
								class="layui-inline layui-icon layui-icon-face-smile-b"></i></span>
						</p>
					</div>
				</div>
			</div>
			<div class="layui-col-sm6 layui-col-md3">
				<div class="layui-card">
					<div class="layui-card-header">
						今日收入(纯收入) <span class="layui-badge layui-bg-green layuiadmin-badge">日</span>
					</div>
					<div class="layui-card-body layuiadmin-card-list">

						<p class="layuiadmin-big-font" id="todaysIncome"></p>
						<p>
							本月收入(纯收入) <span class="layuiadmin-span-color" id="monthIncome"><i
								class="layui-inline layui-icon layui-icon-rmb"></i></span>
						</p>
					</div>
				</div>
			</div>
			<div class="layui-col-sm6 layui-col-md3">
				<div class="layui-card">
					<div class="layui-card-header">
						等待您审核 <span class="layui-badge layui-bg-orange layuiadmin-badge">条</span>
					</div>
					<div class="layui-card-body layuiadmin-card-list">

						<p class="layuiadmin-big-font">66,666</p>
						<p>
							已审核 <span class="layuiadmin-span-color">15% <i
								class="layui-inline layui-icon layui-icon-user"></i></span>
						</p>
					</div>
				</div>
			</div>
			<div class="layui-col-sm6 layui-col-md3">
				<div class="layui-card">
					<div class="layui-card-header">
						财务总金额<span class="layui-badge layui-bg-orange layuiadmin-badge">元</span>
					</div>
					<div class="layui-card-body layuiadmin-card-list">

						<p class="layuiadmin-big-font sumMoney"></p>
						<p>
							财务总金额<span class="layuiadmin-span-color sumMoney"><i
								class="layui-inline layui-icon layui-icon-rmb"></i></span>
						</p>
					</div>
				</div>
			</div>
			<div class="layui-col-sm12">
				<div class="layui-card">
					<div class="layui-card-header">
						销售量排名前十数据统计&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="layui-btn layui-btn-xs" href="#tongji">查看详情</a>
						<div class="layuiadmin-btn-group" style="position:absolute;top:0px;">
							<div class="layui-inline">
								<div class="layui-input-inline">
									<input type="text" class="layui-input year" id="dateOne"
										placeholder="请选择年份" style="height:30px;width:120px;position:relative;top:-2px;left:-10px;">
								</div>
							</div>
						</div>
					</div>
					<div class="layui-card-body">
						<div class="layui-row">
							<div class="layui-col-sm8 innerbox" style="width:100%;overflow-x:auto;">
								<div id="salesNumber" style="width:100%;height:400px;">
									
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-col-sm12">
				<div class="layui-card">
					<div class="layui-card-header">
						销售总金额与成本总金额对比图&nbsp;&nbsp;&nbsp;&nbsp;/&nbsp;&nbsp;&nbsp;&nbsp;销售总金额及毛利对比图
						<div class="layuiadmin-btn-group" style="position:absolute;top:0px;">
							<div class="layui-inline">
							<div class="layui-input-inline">
								<input type="text" class="layui-input year" id="dateTwo"
									placeholder="请选择年份" style="height:30px;width:120px;position:relative;top:-2px;left:-10px;">
							</div>
						</div>
						</div>
					</div>
					<div class="layui-card-body">
						<div class="layui-row">
							<div class="layui-col-sm8 innerbox" style="width:50%;overflow-x:auto;">
								<div id="salesPrice" style="width:100%;height:400px;">
									
								</div>
							</div>
							<div class="layui-col-sm4 innerbox" style="width:50%;overflow-x:auto;">
								<div id="salesSumMoney" style="width:100%;height:400px;">
								
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-col-sm8" style="width:100%">
				<div class="layui-row layui-col-space15">
					<div class="layui-col-sm6">
						<div class="layui-card">
							<div class="layui-card-header">
								药品年销售量占年总销售的百分比
								<div class="layuiadmin-btn-group" style="position:absolute;top:0px;">
									<div class="layui-inline">
									<div class="layui-input-inline">
										<input type="text" class="layui-input year" id="dateThree"
											placeholder="请选择年份" style="height:30px;width:120px;position:relative;top:-2px;left:-10px;">
									</div>
								</div>
								</div>
							</div>
							<div class="layui-card-body" id="salesProportion" style="width:100%;height:316px">
								
							</div>
						</div>
					</div>
					<div class="layui-col-sm6">
						<div class="layui-card">
							<div class="layui-card-header">
								<a name="tongji">销售量数排行表(每年每月的总销售量)</a>
								<div class="layuiadmin-btn-group"
									style="position: absolute; top: 0px;">
									<div class="layui-inline">
										<div class="layui-input-inline">
											<input type="text" class="layui-input year" id="dateFour"
												placeholder="请选择年份"
												style="height: 30px; width: 120px; position: relative; top: -2px; left: -10px;">
										</div>
									</div>
								</div>
							</div>
							<div class="layui-card-body">
								<table class="layui-table" lay-data="{height:315, url:'../../SalesStatistics/findAllSalesStatistics.action?filId=1&num=2', page:true, id:'SalesStatistics',size:'sm',totalRow: true}" lay-filter="test">
								  <thead>
								    <tr>
								      <th lay-data="{field:'drugName', width:100,totalRowText: '合计：',fixed:'left'}">药品名称</th>
								      <th lay-data="{field:'oneMonth', width:80,totalRow: true}">1月</th>
								      <th lay-data="{field:'twoMonth', width:80,totalRow: true}">2月</th>
								      <th lay-data="{field:'threeMonth', width:80,totalRow: true}">3月</th>
								      <th lay-data="{field:'fourMonth', width:80,totalRow: true}">4月</th>
								      <th lay-data="{field:'fiveMonth', width:80,totalRow: true}">5月</th>
								      <th lay-data="{field:'sixMonth', width:80,totalRow: true}">6月</th>
								      <th lay-data="{field:'sevenMonth', width:80,totalRow: true}">7月</th>
								      <th lay-data="{field:'eightMonth', width:80,totalRow: true}">8月</th>
								      <th lay-data="{field:'nineMonth', width:80,totalRow: true}">9月</th>
								      <th lay-data="{field:'tenMonth'}, width:80,totalRow: true">10月</th>
								      <th lay-data="{field:'elevenMonth', width:80,totalRow: true}">11月</th>
								      <th lay-data="{field:'twelveMonth', width:80,totalRow: true}">12月</th>
								      <th lay-data="{field:'sumNumber', width:80,totalRow: true}">年销量</th>
								    </tr>
								  </thead>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-col-sm8" style="width:100%">
				<div class="layui-row layui-col-space15">
					<div class="layui-col-sm6">
						<div class="layui-card">
							<div class="layui-card-header"><a name="inventoryRecord">库存预警</a></div>
							<div class="layui-card-body" id="salesProportion">
								<table class="layui-table" lay-data="{height:315, url:'../../SalesStatistics/findAllSalesStatistics.action?filId=1&num=2', page:true, id:'test',size:'sm'}" lay-filter="test">
								  <thead>
								    <tr>
								      <th lay-data="{field:'drugName', width:100,fixed:'left'}">药品名称</th>
								      <th lay-data="{field:'oneMonth', width:80}">1月</th>
								      <th lay-data="{field:'twoMonth', width:80}">2月</th>
								      <th lay-data="{field:'threeMonth', width:80}">3月</th>
								      <th lay-data="{field:'fourMonth', width:80}">4月</th>
								      <th lay-data="{field:'fiveMonth', width:80}">5月</th>
								      <th lay-data="{field:'sixMonth', width:80}">6月</th>
								      <th lay-data="{field:'sevenMonth', width:80}">7月</th>
								      <th lay-data="{field:'eightMonth', width:80}">8月</th>
								      <th lay-data="{field:'nineMonth', width:80}">9月</th>
								      <th lay-data="{field:'tenMonth'}, width:80">10月</th>
								      <th lay-data="{field:'elevenMonth', width:80}">11月</th>
								      <th lay-data="{field:'twelveMonth', width:80}">12月</th>
								      <th lay-data="{field:'totalNumber', width:80}">年销量</th>
								    </tr>
								  </thead>
								</table>
							</div>
						</div>
					</div>
					<div class="layui-col-sm6">
						<div class="layui-card">
							<div class="layui-card-header">政策维护</div>
							<div class="layui-card-body">
								<table class="layui-table" lay-data="{height:315, url:'../../SalesStatistics/findAllSalesStatistics.action?filId=1&num=2', page:true, id:'test',size:'sm'}" lay-filter="test">
								  <thead>
								    <tr>
								      <th lay-data="{field:'drugName', width:100,fixed:'left'}">药品名称</th>
								      <th lay-data="{field:'oneMonth', width:80}">1月</th>
								      <th lay-data="{field:'twoMonth', width:80}">2月</th>
								      <th lay-data="{field:'threeMonth', width:80}">3月</th>
								      <th lay-data="{field:'fourMonth', width:80}">4月</th>
								      <th lay-data="{field:'fiveMonth', width:80}">5月</th>
								      <th lay-data="{field:'sixMonth', width:80}">6月</th>
								      <th lay-data="{field:'sevenMonth', width:80}">7月</th>
								      <th lay-data="{field:'eightMonth', width:80}">8月</th>
								      <th lay-data="{field:'nineMonth', width:80}">9月</th>
								      <th lay-data="{field:'tenMonth'}, width:80">10月</th>
								      <th lay-data="{field:'elevenMonth', width:80}">11月</th>
								      <th lay-data="{field:'twelveMonth', width:80}">12月</th>
								      <th lay-data="{field:'totalNumber', width:80}">年销量</th>
								    </tr>
								  </thead>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="layui-col-sm8" style="width:100%">
				<div class="layui-row layui-col-space15">
					<div class="layui-col-sm6">
						<div class="layui-card">
							<div class="layui-card-header">
								库存记录信息
								<div class="layuiadmin-btn-group layui-form" style="position: absolute; top: 0px;">
									<div class="layui-input-inline" style="width:120px;">
										<select name="InventoryRecord" lay-verify="" lay-search style="border:none;" lay-filter="type">
											<option value="">入库/出库</option>
											<option value="入库">入库</option>
											<option value="出库">出库</option>
										</select>
									</div>
								</div>
							</div>
							<div class="layui-card-body" id="salesProportion">
								<table class="layui-table" lay-data="{height:315, url:'../../InventoryRecord/findByFilId.action?filId=1', page:true, id:'InventoryRecord',size:'sm',totalRow: true}" lay-filter="test">
								  <thead>
								    <tr>
								      <th lay-data="{field:'numbers', width:100,totalRowText: '合计：',fixed:'left'}">批次号</th>
								      <th lay-data="{field:'matNum', width:80,totalRow: true}">物品数量</th>
								      <th lay-data="{field:'irType', width:80}">记录类型</th>
								      <th lay-data="{field:'irRemark', width:80}">记录备注</th>
								      <th lay-data="{field:'filName', width:100}">公司名称</th>
								      <th lay-data="{field:'irTimes', width:100}">出库/入库日期</th>
								      <th lay-data="{fixed:'right', width:130,align:'center',toolbar: '#barDemo'}">操作</th>
								    </tr>
								  </thead>
								</table>
							</div>
						</div>
					</div>
					<div class="layui-col-sm6">
						<div class="layui-card">
							<div class="layui-card-header">
								财务记录信息
								<div class="layuiadmin-btn-group layui-form" style="position: absolute; top: 0px;">
									<div class="layui-input-inline" style="width:120px;">
										<select name="FinancialRecord" lay-verify="" lay-search lay-filter="type">
											<option value="">收入/支出</option>
											<option value="收入">收入</option>
											<option value="支出">支出</option>
										</select>
									</div>
								</div>
							</div>
							<div class="layui-card-body">
								<table class="layui-table" lay-data="{height:315, url:'../../FinancialRecord/findByFsId.action?fsId=1', page:true, id:'FinancialRecord',size:'sm',totalRow: true}" lay-filter="test">
								  <thead>
								    <tr>
								      <th lay-data="{field:'frId', width:116,totalRowText: '合计：'}">财务记录ID</th>
								      <th lay-data="{field:'frName', width:120}">支出或收入</th>
								      <th lay-data="{field:'frSumprice', width:120,totalRow: true}">财务记录总金额</th>
								      <th lay-data="{field:'frRemark', width:120}">财务记录备注</th>
								      <th lay-data="{field:'frTimes', width:144}">时间</th>
								      <th lay-data="{fixed:'right', width:130,align:'center',toolbar: '#barDemos'}">操作</th>
								    </tr>
								  </thead>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	</div>

	<script src="../../layui/layui.js"></script>
	<script type="text/javascript" src="../../res/js/base.js"></script>
	<script src="../../res/js/tl/echarts.min.js"></script>
	<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
	<script type="text/html" id="barDemo">
      <a class="layui-btn layui-btn-xs" lay-event="ck">查看记录详情</a>
	</script>
	<script type="text/html" id="barDemos">
      <a class="layui-btn layui-btn-xs" lay-event="detail">查看记录详情</a>
	</script>
	<script type="text/javascript">
		$(function(){
			var data = {"filId":1,"page":1,"limit":10,"num":1};
			chartOne(data);
			
			var data = {"filId":1,"page":1,"limit":6,"num":1};
			chartTwo(data);
			
			var data = {"filId":1,"page":1,"limit":6,"num":2};
			chartThree(data);
			
			var data = {"filId":1,"page":1,"limit":10};
			chartFour(data);
		});
		function chartOne(data){
			var url = getRootPath()+"SalesStatistics/findAllSalesStatistics.action";
			$.post(url,data,function(msg){
				var salesNumber = echarts.init(document.getElementById('salesNumber'));
				option = {
					    tooltip : {
					        trigger: 'axis',
					        axisPointer: {
					            type: 'cross',
					            label: {
					                backgroundColor: '#6a7985'
					            }
					        }
					    },
					    legend: {
					    	data : msg.drugName
					    },
					    toolbox: {
					        feature: {
					            saveAsImage: {}
					        }
					    },
					    grid: {
					        left: '1%',
					        right: '4%',
					        bottom: '3%',
					        containLabel: true
					    },
					    xAxis : [
					        {
					            type : 'category',
					            boundaryGap : false,
					            data:['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
					        }
					    ],
					    yAxis : [
					        {
					            type : 'value'
					        }
					    ],
					    series : msg.list
					};
			    // 使用刚指定的配置项和数据显示图表。
			    salesNumber.setOption(option);
			 });
		}
		function chartTwo(data){
			var url = getRootPath()+"SalesStatistics/findTotalCostAllPriceAndSalesProfit.action";
			$.post(url,data,function(msg){
				var salesPrice = echarts.init(document.getElementById('salesPrice'));
				 option = {
					//color: ['#3398DB'],
				    tooltip : {
				    	trigger: 'axis'
				    },
				    legend: {
		                data:['销售总金额','成本总金额']
		            },
				    grid: {
				        left: '1%',
				        right: '4%',
				        bottom: '3%',
				        containLabel: true
				    },
				    toolbox: {
				        feature: {
				            saveAsImage: {}
				        }
				    },
				    xAxis : [
				        {
				            type : 'category',
				            data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
				            boundaryGap: false,
				        }
				    ],
				    yAxis : [
				        {
				            type : 'value'
				        }
				    ],
				    series : [
				    	{
				            name:'销售总金额',
				            type:'line',
				            data:msg.numTwo
				        },{
				            name:'成本总金额',
				            type:'line',
				            data:msg.numOne
				        }
				    ]
				};
			    // 使用刚指定的配置项和数据显示图表。
			    salesPrice.setOption(option);
			 });
		}
		function chartThree(data){
			var url = getRootPath()+"SalesStatistics/findTotalCostAllPriceAndSalesProfit.action";
			$.post(url,data,function(msg){
				var salesSumMoney = echarts.init(document.getElementById('salesSumMoney'));
				 option = {
					tooltip : {
				        trigger: 'axis',
				        axisPointer : {            // 坐标轴指示器，坐标轴触发有效
				            type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				        }
				    },
				    legend: {
				        data:['销售总金额','毛利']
				    },
				    toolbox: {
				        feature: {
				            saveAsImage: {}
				        }
				    },
				    grid: {
				        left: '3%',
				        right: '4%',
				        bottom: '3%',
				        containLabel: true
				    },
				    xAxis : [
				        {
				            type : 'category',
				            data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
				        }
				    ],
				    yAxis : [
				        {
				            type : 'value'
				        }
				    ],
				    series : [
				        {
				            name:'销售总金额',
				            type:'bar',
				            stack: '金额',
				            data:msg.numTwo
				        },
				        {
				            name:'毛利',
				            type:'bar',
				            stack: '金额',
				            data:msg.numOne
				        }
				    ]
				};

			    // 使用刚指定的配置项和数据显示图表。
			    salesSumMoney.setOption(option);
			 });
		}
		function chartFour(data){
			var url = getRootPath()+"SalesStatistics/findSumNumber.action";
			$.post(url,data,function(msg){
				var salesProportion = echarts.init(document.getElementById('salesProportion'));
			    option = {
			    	    title : {
			    	        text: '排行前十药品年销量占总销量的百分比',
			    	        x:'center'
			    	    },
			    	    tooltip : {
			    	        trigger: 'item',
			    	        formatter: "{a} <br/>{b} : {c} ({d}%)"
			    	    },
			    	    legend: {
			    	        type: 'scroll',
			    	        orient: 'vertical',
			    	        right: 10,
			    	        top: 20,
			    	        bottom: 20
			    	    },
			    	    series : [
			    	        {
			    	            name: '药品名称',
			    	            type: 'pie',
			    	            radius : '55%',
			    	            center: ['40%', '50%'],
			    	            data: msg,
			    	            itemStyle: {
			    	                emphasis: {
			    	                    shadowBlur: 10,
			    	                    shadowOffsetX: 0,
			    	                    shadowColor: 'rgba(0, 0, 0, 0.5)'
			    	                }
			    	            }
			    	        }
			    	    ]
			    	};
			 	// 使用刚指定的配置项和数据显示图表。
			    salesProportion.setOption(option);
			 });
		}
		
	</script>
	<script type="text/javascript">
		//初始化数据表格
		layui.use('table',function(){
			var table = layui.table;
		});
	</script>
	<script>
		layui.use(['laydate','table','form'], function() {
			var laydate = layui.laydate
			,table = layui.table
			,form = layui.form;
			laydate.render({ 
			  elem: '#dateOne'
			  ,type: 'year'
			  ,done: function(value, date, endDate){
				   /*  console.log(value); //得到日期生成的值，如：2017-08-18
				    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
				    console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。 */
				  	var data = {"filId":1,"page":1,"limit":10,"num":"1","salesYear":value};
					chartOne(data);
				  }
			});
			laydate.render({ 
				  elem: '#dateTwo'
				  ,type: 'year'
				  ,done: function(value, date, endDate){
					    /* console.log(value); //得到日期生成的值，如：2017-08-18
					    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
					    console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。 */
					  	var data = {"filId":1,"page":1,"limit":6,"num":1,"salesYear":value};
						chartTwo(data);
						var data = {"filId":1,"page":1,"limit":6,"num":2,"salesYear":value};
						chartThree(data);
					  }
				});
			laydate.render({ 
				  elem: '#dateThree'
				  ,type: 'year'
				  ,done: function(value, date, endDate){
					    /* console.log(value); //得到日期生成的值，如：2017-08-18
					    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
					    console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。 */
						var data = {"filId":1,"page":1,"limit":10,"salesYear":value};
						chartFour(data);
					  }
				});
			laydate.render({ 
				  elem: '#dateFour'
				  ,type: 'year'
				  ,done: function(value, date, endDate){
					   /*  console.log(value); //得到日期生成的值，如：2017-08-18
					    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
					    console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。 */
					    table.reload('SalesStatistics',{
					    	page:{
					    		curr:1
					    	},
					    	where:{
					    		salesYear:value
					    	}
					    });
					  }
				});
			
			table.on('tool(test)', function(obj){ //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
				  var data = obj.data; //获得当前行数据
				  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
				  var title = "";
				  var url = "";
				  if(layEvent === 'ck'){ //查看
					title = "库存记录详情";
					var pwId = data.pwId;
					var irType = data.irType;
					alert("业务ID"+pwId+" 记录类型  "+irType);
					//alert("pwId:"+pwId+"  frType:"+frType);
					if(irType == "零售"){
						alert("零售");
						url = "ZgsSellDetailShowList.html?soId="+pwId;
					}else if(irType == "批发"){
						alert("批发");
						url = "ZgsSellDetailShowList.html?soId="+pwId;
					}else if(irType == "总店销售"){
						alert("总店销售");
						url = "ZgsSellDetailShowList.html?soId="+pwId;
					}else if(irType == "药品入库"){
						alert("质检入库");
						url = "ZgsSellDetailShowList.html?soId="+pwId;
					}
				  } else if(layEvent == 'detail'){
					    title = "财务记录详情";
					    var pwId = data.pwId;
						var frType = data.frType;
						alert("pwId:"+pwId+"  frType:"+frType);
						var url = "";
						if(frType == "1"){
							url = "ZgsSellDetailShowList.html?soId="+pwId;
						}else if(frType == "2"){
							url = "ZgsSellDetailShowList.html?soId="+pwId;
						}else if(frType == "3"){
							url = "ZgsSellDetailShowList.html?soId="+pwId;
						}else if(frType == "4"){
							url = "ZgsSellDetailShowList.html?soId="+pwId;
						}else if(frType == "5"){
							url = "ZgsSellDetailShowList.html?soId="+pwId;
						}
				  }
				  layer.open({
					  type: 2,
					  title: title,
					  area : ['80%' , '85%'],//弹出框大小
					  shift:1,//弹出框动画效果
					  content: url //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
					});
				});
			
			var $ = layui.$;
			$(".layui-icon-search").click(function(event){
				var value = $("#InventoryRecord").val();
				table.reload('InventoryRecord', {
					  page: {
					    curr: 1 //重新从第 1 页开始
					  },
					  where: { //设定异步数据接口的额外参数，任意设
						 matName:value  
					  }
				});
			});
			
			form.on('select(type)', function(data){
				  /* console.log(data.elem); //得到select原始DOM对象
				  console.log(data.value); //得到被选中的值
				  console.log(data.othis); //得到美化后的DOM对象 */
				  var name = $(data.elem).attr("name");
				  if(name == "InventoryRecord"){
					  table.reload('InventoryRecord', {
						  page: {
						    curr: 1 //重新从第 1 页开始
						  },
						  where: { //设定异步数据接口的额外参数，任意设
							 irType:data.value  
						  }
					});
				  }else if(name == "FinancialRecord"){
					  table.reload('FinancialRecord', {
						  page: {
						    curr: 1 //重新从第 1 页开始
						  },
						  where: { //设定异步数据接口的额外参数，任意设
							 frName:data.value  
						  }
					});
				  }
			});
			
			
			var data = {"filId":1,"num":1};
			//查询今日销量
			findTodaysSalesOrMonthSales(data);
			//查询今日收入
			findTodaysIncomeOrMonthIncome(data);
			
			
			var data = {"filId":1,"num":2};
			//查询月销量
			findTodaysSalesOrMonthSales(data);
			//查询月收入
			findTodaysIncomeOrMonthIncome(data);
			
			//查询财务总金额
			var url = getRootPath()+"SalesStatistics/findSumMoney.action";
			var data = {"filId":1};
			$.ajax({
				url:url,
				data:data,
				success:function(msg){
					$(".sumMoney").prepend(msg);
				}
			});
		});
		
		function findTodaysSalesOrMonthSales(data){
			var url = getRootPath()+"SalesStatistics/findTodaysSalesOrMonthSales.action";
			var data = data;
			$.ajax({
				url:url,
				data:data,
				success:function(msg){
					if(data.num == "1"){
						$("#todaysSales").prepend(msg);
					}else if(data.num == "2"){
						$("#monthSales").prepend(msg);
					}
				}
			});
		}
		
		function findTodaysIncomeOrMonthIncome(data){
			var url = getRootPath()+"SalesStatistics/findTodaysIncomeOrMonthIncome.action";
			var data = data;
			$.ajax({
				url:url,
				data:data,
				success:function(msg){
					if(data.num == "1"){
						$("#todaysIncome").prepend(msg);
					}else if(data.num == "2"){
						$("#monthIncome").prepend(msg);
					}
				}
			});
		}
	</script>

</body>
</html>